﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.ComponentModel;

namespace EIA.SLClient.ProjectManage.Basic
{
    public class ProjectTitleViewModel : SimpleMvvmToolkit.ViewModelBase<ProjectTitleViewModel>
	{
		public ProjectTitleViewModel()
		{
            RegisterToReceiveMessages<object, EIA.PM.Model.TProjectBasic>(EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.PROJECT_CURRENT, EP_ProjectCurrent);
            RegisterToReceiveMessages<EIA.PM.Model.TProjectBasic>(EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.PROJECT_DETAIL_SHOW, EP_Show);
            RegisterToReceiveMessages<EIA.PM.Model.TProjectBasic>(EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.PROJECT_DETAIL_HIDE, EP_Hide);
		}

        private void EP_ProjectCurrent(object sender, SimpleMvvmToolkit.NotificationEventArgs<object,EIA.PM.Model.TProjectBasic> e)
        {
            if (e!= null && e.Completed != null) e.Completed(ProjectBasic);
        }
        private void EP_Show(object sender, SimpleMvvmToolkit.NotificationEventArgs<EIA.PM.Model.TProjectBasic> e)
        {
            ProjectBasic = e.Data;
        }
        private void EP_Hide(object sender, SimpleMvvmToolkit.NotificationEventArgs e)
        {
            ProjectBasic = null;
        }

        protected EIA.PM.Model.TProjectBasic _ProjectBasic;
        /// <summary>
        /// 注释
        /// </summary>
        public EIA.PM.Model.TProjectBasic ProjectBasic
        {
            get { return _ProjectBasic; }
            set
            {
                _ProjectBasic = value;
                NotifyPropertyChanged(m => m.ProjectBasic);
            }
        }


        #region HideDetailCommand

        private SimpleMvvmToolkit.DelegateCommand _HideDetailCommand = null;
        public SimpleMvvmToolkit.DelegateCommand HideDetailCommand
        {
            get
            {
                if (_HideDetailCommand == null)
                {
                    _HideDetailCommand = new SimpleMvvmToolkit.DelegateCommand(HideDetail, CanExcuteHideDetail);
                } return _HideDetailCommand;
            }
            set { _HideDetailCommand = value; NotifyPropertyChanged(m => m.HideDetailCommand); }
        }

        public void HideDetail()
        {
            SendMessage(EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.PROJECT_DETAIL_HIDE, new SimpleMvvmToolkit.NotificationEventArgs());
        }

        public bool CanExcuteHideDetail()
        {
            return true;
        }

        #endregion

	}
}